package com.heng.futureDemo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class ACompletableFutureMallDemo7 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> stringCompletableFuture = CompletableFuture.supplyAsync(() -> {
            return "hello 1234";
        });

        CompletableFuture<String> stringCompletableFuture1 = CompletableFuture.supplyAsync(() -> {
            return "hello 4";
        });

        CompletableFuture<String> stringCompletableFuture2 = stringCompletableFuture.thenCombine(stringCompletableFuture1, (s1, s2) -> {
            System.out.println(stringCompletableFuture.join());
            System.out.println(stringCompletableFuture1.join());

            return s1 + s2;
        });

        String join = stringCompletableFuture2.join();
        System.out.println(join);


    }
}

